<?php

declare(strict_types=1);

namespace app\shop\controller;

use app\shop\controller\Base;
use app\model\Column;
use think\facade\Request;
use app\model\Goods;
use app\model\GoodsCat;
use app\model\GoodsSpec;

/**
 * @name 详情类
 */
class Detail extends Base
{
    /**
     * @name 商品详情
     */
    public function shopdetails()
    {
        if (request()->isPost()) {
            $id = Request::param('id');
            $find = Goods::find($id);
            if ($find) {
                $spec = GoodsSpec::list($find['id']);
                $find['spec'] = $spec;
                $find['goods_img'] = explode(',', $find['goods_img']);
                return json(['code' => 0, 'msg' => '操作成功', 'data' => $find]);
            } else {
                return json(['code' => 200, 'msg' => '参数错误']);
            }
        };
    }
}
